{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'mesolitica-tpu.json'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from google.cloud import storage\n",
    "client = storage.Client()\n",
    "bucket = client.bucket('mesolitica-tpu-general')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['00.jsonl-29.translated.txt.tsv',\n",
       " '00.jsonl-21.translated.txt.tsv',\n",
       " '00.jsonl-13.translated.txt.tsv',\n",
       " '00.jsonl-31.translated.txt.tsv',\n",
       " 'filtered-dumping-academia.txt.tsv',\n",
       " '00.jsonl-18.translated.txt-pair.tsv',\n",
       " '00.jsonl-27.translated.txt.tsv',\n",
       " '00.jsonl-8.translated.txt.tsv',\n",
       " '00.jsonl-31.translated.txt-pair.tsv',\n",
       " '00.jsonl-0.translated.txt-pair.tsv',\n",
       " '00.jsonl-20.translated.txt.tsv',\n",
       " '00.jsonl-11.translated.txt-pair.tsv',\n",
       " '00.jsonl-23.translated.txt.tsv',\n",
       " '00.jsonl-10.translated.txt.tsv',\n",
       " '00.jsonl-30.translated.txt-pair.tsv',\n",
       " '00.jsonl-32.translated.txt.tsv',\n",
       " '00.jsonl-10.translated.txt-pair.tsv',\n",
       " '00.jsonl-4.translated.txt-pair.tsv',\n",
       " 'filtered-dumping-wiki.txt.tsv',\n",
       " '00.jsonl-22.translated.txt-pair.tsv',\n",
       " '00.jsonl-27.translated.txt-pair.tsv',\n",
       " '00.jsonl-7.translated.txt-pair.tsv',\n",
       " '00.jsonl-3.translated.txt-pair.tsv',\n",
       " 'ms-en.tsv',\n",
       " '00.jsonl-9.translated.txt-pair.tsv',\n",
       " '00.jsonl-29.translated.txt-pair.tsv',\n",
       " '00.jsonl-22.translated.txt.tsv',\n",
       " '00.jsonl-25.translated.txt-pair.tsv',\n",
       " '00.jsonl-12.translated.txt.tsv',\n",
       " 'dumping-parliament.txt.tsv',\n",
       " '00.jsonl-24.translated.txt.tsv',\n",
       " '00.jsonl-5.translated.txt-pair.tsv',\n",
       " '00.jsonl-15.translated.txt.tsv',\n",
       " 'filtered-dumping-wiki.txt-pair.tsv',\n",
       " '00.jsonl-3.translated.txt.tsv',\n",
       " 'dumping-news.txt-pair.tsv',\n",
       " 'mnli.tsv',\n",
       " '00.jsonl-21.translated.txt-pair.tsv',\n",
       " '00.jsonl-2.translated.txt.tsv',\n",
       " '00.jsonl-14.translated.txt.tsv',\n",
       " '00.jsonl-19.translated.txt-pair.tsv',\n",
       " '00.jsonl-2.translated.txt-pair.tsv',\n",
       " '00.jsonl-32.translated.txt-pair.tsv',\n",
       " '00.jsonl-5.translated.txt.tsv',\n",
       " 'dumping-news.txt.tsv',\n",
       " 'filtered-dumping-academia.txt-pair.tsv',\n",
       " '00.jsonl-26.translated.txt-pair.tsv',\n",
       " '00.jsonl-16.translated.txt-pair.tsv',\n",
       " '00.jsonl-28.translated.txt-pair.tsv',\n",
       " 'dumping-parliament.txt-pair.tsv',\n",
       " '00.jsonl-8.translated.txt-pair.tsv',\n",
       " '00.jsonl-1.translated.txt-pair.tsv',\n",
       " '00.jsonl-6.translated.txt.tsv',\n",
       " '00.jsonl-15.translated.txt-pair.tsv',\n",
       " '00.jsonl-6.translated.txt-pair.tsv',\n",
       " '00.jsonl-4.translated.txt.tsv',\n",
       " '00.jsonl-25.translated.txt.tsv',\n",
       " '00.jsonl-24.translated.txt-pair.tsv',\n",
       " '00.jsonl-7.translated.txt.tsv',\n",
       " 'qa.tsv',\n",
       " '00.jsonl-17.translated.txt-pair.tsv',\n",
       " '00.jsonl-9.translated.txt.tsv',\n",
       " 'newstitle.tsv',\n",
       " '00.jsonl-16.translated.txt.tsv',\n",
       " '00.jsonl-19.translated.txt.tsv',\n",
       " '00.jsonl-17.translated.txt.tsv',\n",
       " '00.jsonl-12.translated.txt-pair.tsv',\n",
       " '00.jsonl-28.translated.txt.tsv',\n",
       " '00.jsonl-20.translated.txt-pair.tsv',\n",
       " '00.jsonl-18.translated.txt.tsv',\n",
       " '00.jsonl-14.translated.txt-pair.tsv',\n",
       " 'snli.tsv',\n",
       " '00.jsonl-23.translated.txt-pair.tsv',\n",
       " '00.jsonl-30.translated.txt.tsv',\n",
       " '00.jsonl-1.translated.txt.tsv',\n",
       " '00.jsonl-0.translated.txt.tsv',\n",
       " 'summarization.tsv',\n",
       " 'en-ms.tsv',\n",
       " '00.jsonl-13.translated.txt-pair.tsv',\n",
       " '00.jsonl-26.translated.txt.tsv',\n",
       " '00.jsonl-11.translated.txt.tsv']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from glob import glob\n",
    "\n",
    "files = glob('*.tsv')\n",
    "files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "00.jsonl-29.translated.txt.tsv\n",
      "00.jsonl-21.translated.txt.tsv\n",
      "00.jsonl-13.translated.txt.tsv\n",
      "00.jsonl-31.translated.txt.tsv\n",
      "filtered-dumping-academia.txt.tsv\n",
      "00.jsonl-18.translated.txt-pair.tsv\n",
      "00.jsonl-27.translated.txt.tsv\n",
      "00.jsonl-8.translated.txt.tsv\n",
      "00.jsonl-31.translated.txt-pair.tsv\n",
      "00.jsonl-0.translated.txt-pair.tsv\n",
      "00.jsonl-20.translated.txt.tsv\n",
      "00.jsonl-11.translated.txt-pair.tsv\n",
      "00.jsonl-23.translated.txt.tsv\n",
      "00.jsonl-10.translated.txt.tsv\n",
      "00.jsonl-30.translated.txt-pair.tsv\n",
      "00.jsonl-32.translated.txt.tsv\n",
      "00.jsonl-10.translated.txt-pair.tsv\n",
      "00.jsonl-4.translated.txt-pair.tsv\n",
      "filtered-dumping-wiki.txt.tsv\n",
      "00.jsonl-22.translated.txt-pair.tsv\n",
      "00.jsonl-27.translated.txt-pair.tsv\n",
      "00.jsonl-7.translated.txt-pair.tsv\n",
      "00.jsonl-3.translated.txt-pair.tsv\n",
      "ms-en.tsv\n",
      "00.jsonl-9.translated.txt-pair.tsv\n",
      "00.jsonl-29.translated.txt-pair.tsv\n",
      "00.jsonl-22.translated.txt.tsv\n",
      "00.jsonl-25.translated.txt-pair.tsv\n",
      "00.jsonl-12.translated.txt.tsv\n",
      "dumping-parliament.txt.tsv\n",
      "00.jsonl-24.translated.txt.tsv\n",
      "00.jsonl-5.translated.txt-pair.tsv\n",
      "00.jsonl-15.translated.txt.tsv\n",
      "filtered-dumping-wiki.txt-pair.tsv\n",
      "00.jsonl-3.translated.txt.tsv\n",
      "dumping-news.txt-pair.tsv\n",
      "mnli.tsv\n",
      "00.jsonl-21.translated.txt-pair.tsv\n",
      "00.jsonl-2.translated.txt.tsv\n",
      "00.jsonl-14.translated.txt.tsv\n",
      "00.jsonl-19.translated.txt-pair.tsv\n",
      "00.jsonl-2.translated.txt-pair.tsv\n",
      "00.jsonl-32.translated.txt-pair.tsv\n",
      "00.jsonl-5.translated.txt.tsv\n",
      "dumping-news.txt.tsv\n",
      "filtered-dumping-academia.txt-pair.tsv\n",
      "00.jsonl-26.translated.txt-pair.tsv\n",
      "00.jsonl-16.translated.txt-pair.tsv\n",
      "00.jsonl-28.translated.txt-pair.tsv\n",
      "dumping-parliament.txt-pair.tsv\n",
      "00.jsonl-8.translated.txt-pair.tsv\n",
      "00.jsonl-1.translated.txt-pair.tsv\n",
      "00.jsonl-6.translated.txt.tsv\n",
      "00.jsonl-15.translated.txt-pair.tsv\n",
      "00.jsonl-6.translated.txt-pair.tsv\n",
      "00.jsonl-4.translated.txt.tsv\n",
      "00.jsonl-25.translated.txt.tsv\n",
      "00.jsonl-24.translated.txt-pair.tsv\n",
      "00.jsonl-7.translated.txt.tsv\n",
      "qa.tsv\n",
      "00.jsonl-17.translated.txt-pair.tsv\n",
      "00.jsonl-9.translated.txt.tsv\n",
      "newstitle.tsv\n",
      "00.jsonl-16.translated.txt.tsv\n",
      "00.jsonl-19.translated.txt.tsv\n",
      "00.jsonl-17.translated.txt.tsv\n",
      "00.jsonl-12.translated.txt-pair.tsv\n",
      "00.jsonl-28.translated.txt.tsv\n",
      "00.jsonl-20.translated.txt-pair.tsv\n",
      "00.jsonl-18.translated.txt.tsv\n",
      "00.jsonl-14.translated.txt-pair.tsv\n",
      "snli.tsv\n",
      "00.jsonl-23.translated.txt-pair.tsv\n",
      "00.jsonl-30.translated.txt.tsv\n",
      "00.jsonl-1.translated.txt.tsv\n",
      "00.jsonl-0.translated.txt.tsv\n",
      "summarization.tsv\n",
      "en-ms.tsv\n",
      "00.jsonl-13.translated.txt-pair.tsv\n",
      "00.jsonl-26.translated.txt.tsv\n",
      "00.jsonl-11.translated.txt.tsv\n"
     ]
    }
   ],
   "source": [
    "for file in files:\n",
    "    print(file)\n",
    "    blob = bucket.blob(f't5-data-v2/{file}')\n",
    "    blob.upload_from_filename(file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "for file in files:\n",
    "    os.remove(file)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
